package loggerhelper

import (
	logrus 
)

//Dict 简化键值对的写法
type Dict map[string]interface{}

//New 初始化log的配置
func () *logrus.Logger {
	 := logrus.New()
	.SetFormatter(&logrus.JSONFormatter{})
	return 
}

//Logger 默认的logger
var Logger = New()

//默认的Log对象
var defaultlog *logrus.Entry

//Init 初始化默认的log对象
//@params opts ...Option 初始化使用的参数,具体可以看options.go文件
func ( ...Option) {
	 := DefaultOpts
	for ,  := range  {
		.Apply(&)
	}
	if .Output != nil {
		Logger.SetOutput(.Output)
	}
	var  logrus.Formatter
	if .Type == FormatType_Text {
		 := &logrus.TextFormatter{}
		if .DisableTimeField {
			.DisableTimestamp = true
		}
		if .TimeFormat != "" {
			.TimestampFormat = .TimeFormat
		}
		if .DefaultFieldMap != nil {
			.FieldMap = .DefaultFieldMap
		}
		 = 
	} else {
		 := &logrus.JSONFormatter{}
		if .DisableTimeField {
			.DisableTimestamp = true
		}
		if .TimeFormat != "" {
			.TimestampFormat = .TimeFormat
		}
		if .DefaultFieldMap != nil {
			.FieldMap = .DefaultFieldMap
		}
		 = 
	}
	Logger.SetFormatter()
	Logger.SetLevel(.Level)
	for ,  := range .Hooks {
		Logger.Hooks.Add()
	}
	if .ExtFields == nil || len(.ExtFields) == 0 {
		return
	}
	defaultlog = Logger.WithFields(.ExtFields)
}

//Trace 默认log打印Trace级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Trace()
			}
		case 1:
			{
				Logger.WithFields([0]).Trace()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Trace()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Trace()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Trace()
			}
		}
	}
}

//Debug 默认log打印Debug级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Debug()
			}
		case 1:
			{
				Logger.WithFields([0]).Debug()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Debug()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Debug()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Debug()
			}
		}
	}
}

//Info 默认log打印Info级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Info()
			}
		case 1:
			{
				Logger.WithFields([0]).Info()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Info()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Info()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Info()
			}
		}
	}
}

//Warn 默认log打印Warn级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Warn()
			}
		case 1:
			{
				Logger.WithFields([0]).Warn()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Warn()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Warn()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Warn()
			}
		}
	}
}

//Error 默认log打印Error级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Error()
			}
		case 1:
			{
				Logger.WithFields([0]).Error()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Error()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Error()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Error()
			}
		}
	}
}

//Fatal 默认log打印Fatal级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Fatal()
			}
		case 1:
			{
				Logger.WithFields([0]).Fatal()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Fatal()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Fatal()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Fatal()
			}
		}
	}
}

//Panic 默认log打印Panic级别信息
//@params message string 事件消息
//@params fields ...map[string]interface{} 信息字段
func ( string,  ...map[string]interface{}) {
	 := len()
	if defaultlog == nil {
		switch  {
		case 0:
			{
				Logger.Panic()
			}
		case 1:
			{
				Logger.WithFields([0]).Panic()
			}
		default:
			{
				 := Logger.WithFields([0])
				for ,  := range [1:] {
					 = .WithFields()
				}
				.Panic()
			}
		}
	} else {
		switch  {
		case 0:
			{
				defaultlog.Panic()
			}
		default:
			{
				 := defaultlog
				for ,  := range  {
					 = .WithFields()
				}
				.Panic()
			}
		}
	}
}